package aword.analyze ;

/* Needed for the lexer. */
import java_cup.runtime.* ;




/* ============================================================ */  
/* ============================================================ */
%%

%public
%class LexicalAnalyzer /* Lexer class name.						*/

%line		/* Tells the lexer to remember line numbers.		*/
%column		/* Tells the lexer to remember column numbers.		*/

%type Symbol 	/* Default type used for tokens.				*/
/* Executed when the end of the file is reached.				*/
%eofval{
	return symbol(LexicalUnits.EOF) ;
%eofval}

/* Name of the class containing the codes for the tokens.		*/
%cupsym LexicalUnits
/* Tells the lexer that it will be used with a (CUP) parser.	*/
%cup

/* Custom fields and fonctions for the lexer class.				*/ 
%{
	/**
	 * Used to combine the text from paragraph (as it is read char
	 * by char).
	 */
	private StringBuilder buffer ;
	
	/**
	 * Used to know if the current state is 'Table'.
	 */
	 private boolean intoTable = false ;
	 
	/**
	 * Creates an instance of {@code Symbol} with the given type.
	 * 
	 * @param	type
	 * 			the type of the found token
	 * 
	 * @return	{@code Symbol} with the given type
	 */
	private Symbol symbol(int type) {
		return new Symbol(type, this.yyline, this.yycolumn) ;
	}// symbol(int)
	
	/**
	 * Creates an instance of {@code Symbol} with the given type 
	 * and the given value.
	 * 
	 * @param	type
	 * 			the type of the found token
	 * 
	 * @param	value
	 * 			value added to the found token
	 * 
	 * @return	{@code Symbol} with the given type and value
	 */
	private Symbol symbol(int type, Object value) {
		return new Symbol(type, this.yyline, this.yycolumn, value) ;
	}// symbol(int, Object)
	
	/**
	 * Extract the style name from the
	 */
	private String extractStyleName(String styleExp) {
		return styleExp.substring(7).replaceAll("\".*", "") ;
	}
	
	/**
	 * Extract the value from an attribute.
	 *
	 * <p>The attribute is assumed to follow the given format :
	 * <pre>&lt;name>="&lt:value>" and return the value.</pre>
	 */
	private String extractValue(String attribute) {
		int valueStart = 0, valueEnd = attribute.length()-1 ;
		while (attribute.charAt(valueStart) != '"') {
			valueStart++ ;
		}// while
		while (attribute.charAt(valueEnd) != '"') {
			valueEnd-- ;
		}// while
		return attribute.substring(valueStart+1, valueEnd) ;
	}// extractValue(String)
	
	/**
	 * Extract cell's text alignment property
	 */
	private String extractCellTextAlign(String jcExp) {
		return jcExp.substring(13).replaceAll("\"/>", "") ;
	}
	
	/**
	 * Extract a link destination for links which surround text parts
	 * e.g. : <w:hlink w:dest="http://truc.php">
	 *				[...]
	 *					<w:t>Ici truc.php</w:t>
	 *			</w:hlink>
	 */
	private String extractLinkDest1(String linkExp) {
		return linkExp.substring(17).replaceAll("\".*>", "") ;
	}
	
	/**
	 * Extract a link destination for links which don't surround text parts
	 * e.g. : <w:hlink w:dest="http://truc.php"/>
	 */
	private String extractLinkDest2(String linkExp) {
		return linkExp.substring(17).replaceAll("\".*/>", "") ;
	}
	
	/**
	 * Extract an adresse mail for links which surround text parts
	 */
	private String extractMail1(String mailExp) {
		return mailExp.substring(24).replaceAll("\".*>", "") ;
	}
	
	/**
	 * Extract an adresse mail for links which don't surround text parts
	 */
	private String extractMail2(String mailExp) {
		return mailExp.substring(24).replaceAll("\".*/>", "") ;
	}
	
	/**
	 * Extract the gridspan's vaue : the number of coulms merged
	 */
	private String extractNumberMerged(String gridSpan) {
		return gridSpan.substring(19).replaceAll("\".*/>", "") ;
	}
%}

/* Custom states for the lexer 									*/
/* Used within the word document								*/
%state Document
/* Used within a text paragraph									*/
%state Paragraph
/* Used within paragraph properties								*/
%state ParagraphProperties
/* Used to retrieve raw text									*/
%state Text
/* Used to retrieve property attributes							*/
%state Property
/* Used within a table											*/
%state Table
/* Used within tables' columns properties						*/
%state ColumnProperties
/* Used within paragraphs run									*/
%state Run
/* Used within paragraphs run properties						*/
%state RunProperties
/* Used to retrieve pictures                                    */
%state Picture
/* Used to retrieve list definition                             */
%state ListDef
/* Used to ignore headers and footers                           */
%state HeaderOrFooter
/* USed to ignore footnotes										*/
%state Footnote



/* ------------------------------------------------------------ *\
 * 		Document 
\* ------------------------------------------------------------ */
Document = "w:wordDocument"
DocumentStart = <{Document}([^>]*)>
DocumentEnd   = <\/{Document}>


/* ------------------------------------------------------------ *\
 * 		Paragraph 
\* ------------------------------------------------------------ */
/*	Parapgraph													*/
Paragraph = "w:p"
ParagraphStart = <{Paragraph}> | <{Paragraph}[ ][^>/]*>
ParagraphEnd   = <\/{Paragraph}>

/*	Parapgraph properties										*/
ParagraphProperties = "w:pPr"
ParagraphPropertiesStart = <{ParagraphProperties}> | <{ParagraphProperties}[ ][^>]*>
ParagraphPropertiesEnd   = <\/{ParagraphProperties}>

/*	Paragraph run												*/
Run = "w:r"
RunStart = <{Run}> | <{Run}[ ][^>]*>
RunEnd   = <\/{Run}>

/* 	Run properties												*/
RunPropStart = "<w:rPr>"
RunPropEnd = "<\/w:rPr>"

/* Paragraph text												*/
Text = "w:t"
TextStart = <{Text}>
TextEnd   = <\/{Text}>
TextNul = <{Text}\/>
TabChar = <w:tab[^\/]*\/>
LineBreak = <w:br[^\/]*\/>
PageBreak = "<w:br w:type=\"page\"/>"

/* Foot notes													*/
Footnote = w:footnote
FootnoteStart = <{Footnote}>
FootnoteEnd = <\/{Footnote}>


/* ------------------------------------------------------------ *\
 * 		Style 
\* ------------------------------------------------------------ */
/*	Paragraph style tag											*/
Style = "<w:pStyle "
/*	Paragraph style tag	value attribute							*/
StyleName = "w:val=\""[^\"]+"\""

/* ------------------------------------------------------------ *\
 * 		Formatages
\* ------------------------------------------------------------ */
Bold = "<w:b\/>" | "<w:b val=\""(on|off)"\"\/>"
Italic = "<w:i\/>"| "<w:i val=\""(on|off)"\"\/>"
Underlined = "<w:u w:val=\"single\""{UnderlinedColor}{0,1}"\/>"
UnderlinedColor = " w:color=\"\[0-9\]\+\""
Struck = "<w:strike\/>"| "<w:strike val=\""(on|off)"\"\/>"
Superscript = "<w:vertAlign w:val=\"superscript\"\/>"
Subscript = "<w:vertAlign w:val=\"subscript\"\/>"
//A completer, je n'ai pu trouver de liste exhaustive des polices à chasse fixe que l'on pourrait rencontrer
Monospace = "<w:rFonts w:ascii=\"(Courier New|DejaVu Sans Mono|Lucida Console)\" [^>]*\/>"

/* ------------------------------ *\
* 		Table
\* ------------------------------ */
Tab = "w:tbl"
TabStart = <{Tab}>
TabEnd =  <\/{Tab}>
TabRow = "w:tr"
TabRowStart = <{TabRow}> | <{TabRow}[ ][^>]*>
TabRowEnd = <\/{TabRow}>
TabCol = "w:tc"
TabColStart = <{TabCol}>
TabColEnd = <\/{TabCol}>
/* Cell's text alignment tag value attribute					*/
CellTextAlign = "<w:jc w:val=\""(left|center|right)"\"\/>"
/* Columns properties 											*/
ColumnPropertiesStart = "<w:tcPr>"
ColumnPropertiesEnd = "<\/w:tcPr>"
/* Rowspan														*/
Rowspan = "<w:vmerge w:val=\""continue"\"\/>" | "<w:vmerge\/>"
/* Colspan														*/
Colspan = "<w:hmerge w:val=\"continue\"\/>" | "<w:hmerge\/>"
ColspanBis = "<w:gridSpan w:val=\""[0-9]+"\"\/>"


/* ------------------------------------------------------------ *\
*         Lists
\* ------------------------------------------------------------ */
/*    List definitions                                          */
Lists = "w:lists"
ListsStart = <{Lists}>
ListsEnd   = <\/{Lists}>
/*    List definition                                           */
ListDefinition = "w:listDef"
ListDefinitionStart = <{ListDefinition}
ListDefinitionEnd   = <\/{ListDefinition}>
/*    List definition identifier                                    */
ListDefId = "w:listDefId=\""[0-9]+"\""
/*    List definition, level definition                            */
ListLevelDefinition = "w:lvl"
ListLevelDefinitionStart = <{ListLevelDefinition}" "
ListLevelDefinitionEnd   = <\/{ListLevelDefinition}>
/*    List level definition identifier                            */
ListLevel = "w:ilvl=\""[0-9]+"\""
/*    List definition, level definition,
* type definition (bullet or numbered)                            */
ListType = "<w:nfc w:val=\""[0-9]+"\""
/*    List                                                        */
List = "w:list"
ListStart = <{List}" "
ListEnd   = <\/{List}>
/*    List identifier                                                */
ListId = "w:ilfo=\""[0-9]+"\""
/*    List definition    link                                        */
ListLink = "<w:ilst w:val=\""[0-9]+"\""
/*    List definition    link                                        */
ListLink = "<w:ilst w:val=\""[^\"]+"\""
/*    Paragraph list style, level                                    */
ParagraphListLevel = "<w:ilvl w:val=\""[0-9]+"\""
/*    Paragraph list style                                        */
ParagraphListStyle = "<w:ilfo w:val=\""[0-9]+"\""
ListOverride = "<w:lvlOverride".*"</w:lvlOverride>"


/* ------------------------------ *\
*		Link-Mail
\* ------------------------------ */
/* A link which doesn't surround text parts						*/
Link = "<w:hlink w:dest=\""[^>\"]*\" [^>]*"/>"
Mail =  "<w:hlink w:dest=\"mailto:"[^>\"]*\" [^>]*"/>"
/* For a link which surrounds text parts						*/ 
LinkStart = "<w:hlink w:dest=\""[^>\"]*\" [^>]*">"
MailStart = "<w:hlink w:dest=\"mailto:"[^>\"]*\" [^>]*">"
LinkEnd = "<\/w:hlink>"


/* ------------------------------ *\
* 		Picture
\* ------------------------------ */
pictStart = "<w:pict>"
pictEnd = "<\/w:pict>"


/* ------------------------------ *\
* 		Footer and Header
\* ------------------------------ */
Header = "w:hdr"
Footer = "w:ftr"
HeaderOrFooterStart = <({Header}|{Footer})" "[^>]*>
HeaderOrFooterEnd = <\/({Header}|{Footer})>


/* ------------------------------------------------------------ *\
 * 		Other 
\* ------------------------------------------------------------ */
/* A line terminator is a \r (carriage return), \n (line feed), or \r\n. */
LineTerminator = \r|\n|\r\n

/* White space is a line terminator, space, tab, or line feed. */
WhiteSpace     = {LineTerminator} | [ \t\f]




/* ============================================================ */  
/* ============================================================ */
%%

<YYINITIAL> {DocumentStart}
{
	yybegin(Document) ;
//	System.out.printf("Debut document.\n") ;
	return symbol(LexicalUnits.DOCUMENT_START) ;
}

<YYINITIAL> .
{
	//System.out.printf("Autre.\n") ;
	/* just skip what was found, do nothing */ 
}

<Document> {HeaderOrFooterStart}
{
	//System.out.printf("Debut H or F '%s'\n", yytext()) ;
   yybegin(HeaderOrFooter) ;
}

<HeaderOrFooter> {HeaderOrFooterEnd}
{
	//System.out.printf("Fin H or F\n") ;
   yybegin(Document) ;
}

<HeaderOrFooter> . 
{
	//System.out.printf("Milieu H or F\n") ;
	/* just skip what was found, do nothing */ 
}

<Document> {ListsStart}
{
   yybegin(ListDef) ;
   return symbol(LexicalUnits.LISTS_START) ;
}

<Document, Table> {ParagraphStart}
{
	yybegin(Paragraph) ;
//	System.out.printf("Debut paragraphe. --> %s\n", yytext()) ;
	return symbol(LexicalUnits.PARAGRAPH_START) ;
}

<Document> {TabStart}
{
	yybegin(Table);
	intoTable = true;
//	System.out.printf("Debut Tableau\n") ;
	return symbol(LexicalUnits.TABLE_START) ;
}

<Table> {TabRowStart}
{
//	System.out.printf("\n /** Debut Ligne\n") ;
	return symbol(LexicalUnits.ROW_START) ;
}

<Table> {TabColStart}
{
//	System.out.printf("\n/* Début colonne\n") ;
	yybegin(ColumnProperties) ;
	return symbol(LexicalUnits.CELL_START) ; 
}

<ColumnProperties> {ColumnPropertiesStart}
{
//	System.out.printf("Debut propriétés de la colonne.\n") ;
}

<ColumnProperties> {Rowspan}
{
//	System.out.printf("Cellule ROWSPAN.\n") ;
	return symbol(LexicalUnits.VMERGE) ; 
}

<ColumnProperties> {Colspan}
{
//	System.out.printf("Cellule COLSPAN.\n") ;
	return symbol(LexicalUnits.HMERGE) ;
}

<ColumnProperties> {ColspanBis}
{
//	System.out.printf("number merged : "+this.extractNumberMerged(this.yytext())) ;
	Integer merged = Integer.parseInt(this.extractNumberMerged(this.yytext()));
	return symbol(LexicalUnits.GRIDSPAN,merged) ;
}

<ColumnProperties> {ColumnPropertiesEnd}
{
//	System.out.printf("Fin propriétés de la colonne.\n") ;
	//yybegin(Document) ;
	yybegin(Table) ;
}

<ColumnProperties> .
{
	//System.out.printf("Contenu propriétés de la colonne.\n") ;
}

<Table> {TabColEnd}
{
//	System.out.printf("\nFin colonne */\n") ;
	return symbol(LexicalUnits.CELL_END) ; 
}

<Table> {TabRowEnd}
{
//	System.out.printf("Fin ligne **/\n") ;
	return symbol(LexicalUnits.ROW_END) ;  
}

<Table> {TabEnd}
{
	intoTable = false;
//	System.out.printf("Fin Tableau\n") ;
	yybegin(Document);
	return symbol(LexicalUnits.TABLE_END) ; 
}

<Table> .
{
	//System.out.printf("CT ") ;
	/* just skip what was found, do nothing */ 
}

<Document> .
{
	//System.out.printf("Contenu document.\n") ;
	/* just skip what was found, do nothing */ 
}

<Paragraph> {ParagraphPropertiesStart}
{
//	System.out.printf("Début prop. paragraphe\n") ;
	yybegin(ParagraphProperties) ;
	return symbol(LexicalUnits.PROPERTIES_START) ;
}

<ParagraphProperties> {ParagraphListLevel}
{
   return symbol(LexicalUnits.PLIST_LEVEL,
           this.extractValue(this.yytext())) ;
}

<ParagraphProperties> {ParagraphListStyle}
{
   return symbol(LexicalUnits.PLIST_STYLE,
           this.extractValue(this.yytext())) ;
}

<ParagraphProperties> {Style}
{
	//System.out.printf("Style found : '%s'\n",
	//		this.yytext()) ;
	yybegin(Property) ;
	return symbol(LexicalUnits.STYLE) ;
}

<ParagraphProperties> {CellTextAlign}
{
//	System.out.printf("Text alignment found : '%s'\n",
//			this.extractCellTextAlign(this.yytext())) ;
	if(intoTable) {
		return symbol(LexicalUnits.CELL_TEXT_ALIGN,this.extractCellTextAlign(this.yytext())) ;
		}
}
<Property> {StyleName}
{
//	System.out.printf("Style name found : '%s'\n",
//			this.extractStyleName(this.yytext())) ;
	yybegin(ParagraphProperties) ;
	return symbol(LexicalUnits.STYLE_NAME, 
			this.extractStyleName(this.yytext())) ;
}

<ParagraphProperties> {ParagraphPropertiesEnd}
{
//System.out.printf("Leave ParagraphProperties with '%s'\n",
//		this.yytext()) ;
	yybegin(Paragraph) ;
	return symbol(LexicalUnits.PROPERTIES_END) ;
}

<Paragraph> {RunStart}
{
//	System.out.printf("Debut run with %s.\n",this.yytext()) ;
	yybegin(Run);
	return symbol(LexicalUnits.RUN_START) ;
}

<Run> {RunPropStart}
{
//	System.out.printf("Debut propriétés du run.\n") ;
	yybegin(RunProperties);
}

<RunProperties> {Bold}
{
//	System.out.printf("Texte en gras.\n") ;
	return symbol(LexicalUnits.BOLD) ;	
}

<RunProperties> {Italic}
{
//	System.out.printf("Texte en italique.\n") ;
	return symbol(LexicalUnits.ITALIC) ;	
}

<RunProperties> {Underlined}
{
//	System.out.printf("Texte souligné: %s\n",this.yytext()) ;
	return symbol(LexicalUnits.UNDERLINED) ;	
}

<RunProperties> {Struck}
{
//	System.out.printf("Texte barré.\n") ;
	return symbol(LexicalUnits.STRUCK) ;	
}

<RunProperties> {Superscript}
{
//	System.out.printf("Texte en exposant.\n") ;
	return symbol(LexicalUnits.SUPERSCRIPT) ;	
}

<RunProperties> {Subscript}
{
//	System.out.printf("Texte en indice.\n") ;
	return symbol(LexicalUnits.SUBSCRIPT) ;	
}

<RunProperties> {Monospace}
{
//	System.out.printf("Texte à chasse fixe.\n") ;
	return symbol(LexicalUnits.MONOSPACE) ;
}

<RunProperties> {RunPropEnd}
{
//	System.out.printf("Fin des propriétés du run.\n") ;
	yybegin(Run);	
}

<RunProperties> .
{
	/* just skip what was found, do nothing */ 	
}

<Run> {pictStart}
{
//	System.out.printf("Début Image.\n") ;
	return symbol(LexicalUnits.PICTURE_START) ; 	
}

<Run> {pictEnd}
{
//	System.out.printf("Fin image.\n") ;
	return symbol(LexicalUnits.PICTURE_END) ;
}

<Run> {FootnoteStart}
{
	yybegin(Footnote) ;
}

<Footnote> {FootnoteEnd}
{
	yybegin(Run) ;
}

<Footnote> .
{
	/* just skip what was found, do nothing */
}

<Run> .
{
	/* just skip what was found, do nothing */ 	
}



<Paragraph> {Mail}
{
//	System.out.printf("Lien mail sans texte repéré : %s\n",this.yytext()) ;
//	System.out.printf("Adresse mail = %s\n",this.extractMail2(this.yytext())) ;
//	return symbol(LexicalUnits.MAIL,
//			this.extractMail2(this.yytext())) ;
}

<Paragraph> {Link}
{
//	System.out.printf("Lien sans texte repéré: %s\n",this.yytext()) ;
//	System.out.printf("Dest. = %s\n",this.extractLinkDest2(this.yytext())) ;
//	return symbol(LexicalUnits.LINK,
//			this.extractLinkDest2(this.yytext())) ;
}

<Paragraph> {MailStart}
{
//	System.out.printf("Lien mail avec texte repéré: %s\n",this.yytext()) ;
//	System.out.printf("Adresse mail = %s\n",this.extractMail1(this.yytext())) ;
	return symbol(LexicalUnits.MAIL_START,
			this.extractMail1(this.yytext())) ;
}

<Paragraph> {LinkStart}
{
//	System.out.printf("Lien avec texte repéré: %s\n",this.yytext()) ;
//	System.out.printf("Dest = %s\n",this.extractLinkDest1(this.yytext())) ;
	return symbol(LexicalUnits.LINK_START,
			this.extractLinkDest1(this.yytext())) ;
}

<Paragraph> {LinkEnd}
{
//	System.out.printf("Fin lien.\n") ;
	return symbol(LexicalUnits.LINK_END) ;
}

<Run> {TextNul}
{
//	System.out.printf("Pas de texte.\n") ;
//	return symbol(LexicalUnits.TEXT,"") ;
}

<Run> {TabChar}
{
//	System.out.printf("Pas de texte.\n") ;
	return symbol(LexicalUnits.TEXT,"\t") ;
}

<Run> {PageBreak}
{
	//System.out.printf("Saut de page\n") ;
	/* just skip what was found, do nothing */ 	
}

<Run> {LineBreak}
{
//	System.out.printf("Saut de ligne '%s'.\n", this.yytext()) ;
	return symbol(LexicalUnits.LINE_BREAK) ;
}

<Run> {TextStart}
{
	yybegin(Text) ;
//	System.out.printf("Debut texte.\n") ;
	this.buffer = new StringBuilder() ;
}

<Text> {TextEnd}
{
	yybegin(Run) ;
//	System.out.printf("Fin texte : %s\n",buffer.toString()) ;
	return symbol(LexicalUnits.TEXT, this.buffer.toString()) ;
}

<Text> .
{
	buffer.append(this.yytext()) ;
}

<Text> {WhiteSpace}
{
	buffer.append(this.yytext()) ;
}

<Paragraph> {pictStart}
{
//    System.out.printf("Début image.\n") ;
   yybegin(Picture) ;
   return symbol(LexicalUnits.PICTURE_START) ;
}

/*<Picture> {pictEnd}
{
//    System.out.printf("Fin image.\n") ;
   yybegin(Paragraph) ;
   return symbol(LexicalUnits.PICTURE_END) ;
}

<Picture> .
{
   // System.out.printf("Contenu image.\n") ;
}
*/

<Run> {RunEnd}
{
//	System.out.printf("Fin run.\n") ;
	yybegin(Paragraph);
	return symbol(LexicalUnits.RUN_END) ;
}

<Paragraph> {ParagraphEnd}
{
	if(intoTable) {
		yybegin(Table) ;
	}
	else {
		yybegin(Document) ;
	}
//	System.out.printf("Fin paragraphe with %s.\n",this.yytext()) ;
	return symbol(LexicalUnits.PARAGRAPH_END) ;
}

<Document> {DocumentEnd}
{ 
//	System.out.printf("Fin document.\n") ;
	yybegin(YYINITIAL) ;
	return symbol(LexicalUnits.DOCUMENT_END) ;
}

<Paragraph> .
{
	//System.out.printf("Contenu paragraphe.\n") ;
	/* just skip what was found, do nothing */ 
}

<ParagraphProperties> .
{ 
	//System.out.printf("Contenu propriétés paragraphe.\n") ;
	/* just skip what was found, do nothing */ 
}

<ListDef> {ListOverride}
{
	/* Do nothing. */
}

<ListDef> {ListsEnd}
{
//    System.out.printf("ListsEnd : '%s'\n", this.yytext()) ;
   yybegin(Document) ;
   return symbol(LexicalUnits.LISTS_END) ;
}

<ListDef> {ListDefinitionStart}
{
//    System.out.printf("'\nListDefinitionStart : '%s'\n\t'", this.yytext()) ;
   return symbol(LexicalUnits.LIST_DEF_START) ;
}

<ListDef> {ListDefId}
{
//    System.out.printf("'\nListDefId : '%s'\n\t'", this.yytext()) ;
   return symbol(LexicalUnits.LIST_DEF_ID,
           this.extractValue(this.yytext())) ;
}

<ListDef> {ListDefinitionEnd}
{
//    System.out.printf("'\nListDefinitionEnd : '%s'\n\t'", this.yytext()) ;
   return symbol(LexicalUnits.LIST_DEF_END) ;
}

<ListDef> {ListLevelDefinitionStart}
{
//    System.out.printf("'\nListLevelDefinitionStart : '%s'\n\t'", this.yytext()) ;
   return symbol(LexicalUnits.LIST_DEF_LEVEL_START) ;
}

<ListDef> {ListLevel}
{
//    System.out.printf("'\nListLevel : '%s'\n\t'",
//            this.extractValue(this.yytext())) ;
   return symbol(LexicalUnits.LIST_DEF_LEVEL,
           this.extractValue(this.yytext())) ;
}

<ListDef> {ListType}
{
//    System.out.printf("'\nListType : '%s'\n\t'",
//            this.extractValue(this.yytext())) ;
   return symbol(LexicalUnits.LIST_LEVEL_TYPE,
           this.extractValue(this.yytext())) ;
}

<ListDef> {ListLevelDefinitionEnd}
{
//    System.out.printf("'\nListLevelDefinitionEnd : '%s'\n\t'",
//            this.yytext()) ;
   return symbol(LexicalUnits.LIST_DEF_LEVEL_END) ;
}

<ListDef> {ListStart}
{
   return symbol(LexicalUnits.LIST_START) ;
}

<ListDef> {ListId}
{
   return symbol(LexicalUnits.LIST_ID,
           this.extractValue(this.yytext())) ;
}

<ListDef> {ListLink}
{
   return symbol(LexicalUnits.LIST_DEF_ID,
           this.extractValue(this.yytext())) ;
}

<ListDef> {ListEnd}
{
   return symbol(LexicalUnits.LIST_END) ;
}

<ListDef> .
{
//    System.out.printf("%s", this.yytext()) ;
   /* just skip what was found, do nothing */
}
/*//TODO Etat à rajotuer: Picture*/
<YYINITIAL, Document, Paragraph, Table, ColumnProperties, Run, ParagraphProperties,
RunProperties, ListDef, HeaderOrFooter> {WhiteSpace}
{ 
	//System.out.printf("Whitespace.\n") ;
	/* just skip what was found, do nothing */ 
}
/* 	No token was found for the input so through an error.  Print out an
	Illegal character message with the illegal character that was found. */
[^]
{ 
	throw new java.io.IOException(
	  String.format("Échec de l'analyse du fichier Word. (caractère inattendu : '%s', etat courant : %d)\n",
			this.yytext(), this.zzLexicalState)) ;
}